<template>
  <div class="wfull ibk">
    <a-input
      :type="show?'text':'password'"
      :style="{width:width>0?`${width}px`:'100%'}"
      v-model.trim="val"
      :placeholder="placeholder"
      :disabled="disabled">
      <i @click="show=!show" class="fa cpt" :class="show?'fa-eye':'fa-eye-slash'" slot="addonAfter"/>
    </a-input>
  </div>
</template>

<script>
export default {
  model: {
    prop: 'modelVal',
    event: 'change'
  },
  props: {
    modelVal: {
      type: String,
      default: ''
    },
    width: {
      type: Number,
      default: 0
    },
    placeholder: {
      type: String,
      default: '请输入内容'
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      show: false,
      val: ''
    }
  },
  mounted () {
    this.val = this.modelVal
  },
  watch: {
    modelVal (v) {
      this.val = v
    },
    val (v) {
      this.$emit('change', v)
    }
  },
  methods: {
  }
}
</script>
<style lang="scss" scoped>
</style>
